package com.jiutong.meipengdai.http.present;

import android.content.Context;

import com.jiutong.meipengdai.entity.AccountSettingRespond;
import com.jiutong.meipengdai.entity.BaseRespond;
import com.jiutong.meipengdai.http.model.interfaces.MyAccountSettingBiz;
import com.jiutong.meipengdai.http.model.interfaces.MyUserInfoBiz;
import com.jiutong.meipengdai.http.model.requests.MyUserInfoRequest;
import com.jiutong.meipengdai.http.model.requests.UserInfoRequest;
import com.jiutong.meipengdai.http.subscribers.ProgressSubscriber;
import com.jiutong.meipengdai.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * 作用:
 * Created by 78 on 2017/6/27.
 */

public class MyUserInfoPresent {

    private final Context mContext;
    private final MyUserInfoBiz myUserInfoBiz;
    private final MyUserInfoRequest myUserInfoRequest;

    public MyUserInfoPresent(Context context, MyUserInfoBiz myUserInfoBiz) {
        this.mContext = context;
        this.myUserInfoBiz = myUserInfoBiz;
        myUserInfoRequest = new MyUserInfoRequest();
    }


    /**
     * 修改性别/出生日期
     */
    public void editSexBirthday() {
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<BaseRespond>() {
            @Override
            public void onNext(BaseRespond o) {
                myUserInfoBiz.onSuccess(o);
            }

            @Override
            public void onError(Throwable e) {
                myUserInfoBiz.onError(e);
            }
        };
        HashMap<String,Object> fieldsMap=new HashMap<>();
        fieldsMap.put("sex", myUserInfoBiz.getSex());
        fieldsMap.put("birthDay", myUserInfoBiz.getBirthday());
        myUserInfoRequest.getSexBirthday(new ProgressSubscriber(onNextListener,mContext),fieldsMap);
    }
}
